package com.codeczx.mygeeknews;

import android.app.Activity;
import android.app.Application;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by codeczx on 2017/6/16.
 */

public class App extends Application {

    private static App instance;
    private Set<Activity> allActivities;

    public static synchronized App getInstance(){
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
    }

    public void addActivity(Activity activity){
        if (allActivities == null) {
            allActivities = new HashSet<>();
        }
        allActivities.add(activity);
    }

    public void removeActivity(Activity activity){
        if(allActivities!=null){
            allActivities.remove(activity);
        }
    }

}
